import logging

import requests

from api.RegLoginApi import RegLoginApi
from config import URL

ses = requests.session()


class InvestApi:

    def __init__(self, session):
        # 创建session对象
        self.ses = session

    # 获取投资接口
    def get_investment(self, id, depositCertificate, amou):
        url = URL + "/trust/trust/tender"
        body = {"id": id, "depositCertificate": depositCertificate, "amount": amou}
        resp = self.ses.post(url=url, data=body)
        logging.info(f"投资接口的响应体数据{resp.json()}")
        return resp

    # 获取第三方投资接口
    def the_third_investment(self, url, form_dict):
        resp = self.ses.post(url=url, data=form_dict)
        logging.info(f"第三方投资接口的响应体数据{resp.text}")
        return resp


if __name__ == '__main__':
    RegLoginApi(ses).user_login("18373444511", "11111MM")
    resp = InvestApi(ses).get_investment(642, -1, 0)
    print(resp.json())
